<link rel="stylesheet" type="text/css" media="screen" href="themes/base/ui.all.css" />
<script src="jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="ui.datepicker.js"></script>
<script>
$(function() {
		$('#tgldaf').datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd-MM-yy',
			minDate: +0
		});
	});
</script>
<?php 
include'connecsi.php';
$kode_pesanan=$_POST[kode_pesanan];
$tgldaf=$_POST[tgldaf];
$nmps=$_POST[nmps];
$jk=$_POST[jk];
$almt=$_POST[almt];
$umurps=$_POST[umurps];
$telpps=$_POST[telpps];
$simpan=$_GET[simpan];
$bilang=$_GET[bilang];
?>

<?php
			
			$seleksi  = "SELECT ID_PASIEN FROM db_pasien ORDER BY ID_PASIEN DESC";
			$qseleksi = mysql_query($seleksi)
						or die("seleksi nomor gagal " . mysql_error());
			$barisno = mysql_fetch_array($qseleksi);
			?>

<?

$kode_ps=array('0','1','2','3','4','5','6','7','8','9');

shuffle($kode_ps);
reset($kode_ps);

$no=0;
foreach($kode_ps as $line)
{
$kode_pesanan.=strtoupper($line);
$no++;
if (($no >= 5)) break;
} ?>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
<table width="100%" align="center" border="0" cellspacing="1" cellpadding="1" bgcolor="#000000">
<tr><td>
<table width="100%" align="center" border="0" cellspacing="1" cellpadding="1" bgcolor="#ffffff">
<tr><td>
<table width="100%"align="center" border="0" cellspacing="1" cellpadding="1">
  <tr>
	<td></td>
  </tr>
  <tr>
	<td>
	<table width="85%"  border="0" cellspacing="1" cellpadding="1">
	  <tr>
		<td colspan="6">
		<?php
		if($_GET[aksi]=="simpan")
		{
			if((empty($kode_pesanan)) or (empty($tgldaf)) or (empty($nmps))  or (empty($umurps)) or (empty($jk)) or (empty($almt)) or (empty($telpps)))							
			{echo "<script>alert('Lengkapi Form')</script>";
			echo"<meta http-equiv=refresh content=0;URL='home.php?ling=pasien'>";}
			elseif(!is_numeric($umurps))							{echo "<script>alert('Poli Diisi Hanya Angka')</script>";
			echo"<meta http-equiv=refresh content=0;URL='home.php?ling=pasien'>";}
			elseif(!is_numeric($telpps))							{echo "<script>alert('Telp Diisi Hanya Angka')</script>";
			echo"<meta http-equiv=refresh content=0;URL='home.php?ling=pasien'>";}
			else
			{
			$proses_3="insert into db_pasien(ID_PASIEN,TGL_DAFTAR,NAMA_PASIEN,JK_PASIEN,UMUR_PASIEN,ALAMAT_PASIEN,TLP_PASIEN) values ('$kode_pesanan','$tgldaf','$nmps','$jk','$umurps','$almt','$telpps') ";
			$queri_3=mysql_query($proses_3)or die("maaf inputtan gagal");
			if($queri_3)
			{
			echo "<script>alert('Data Masuk Sudah')</script>";echo"<meta http-equiv=refresh content=0;URL='home.php?ling=pasien'>";
			}
			}
		}
		elseif($_GET[aksi]=="hapus")
		{
			$dihapus=mysql_query("delete from db_pasien where ID_PASIEN='$bilang' ");
			if($dihapus)
			{ echo"<meta http-equiv=refresh content=0;URL='home.php?ling=pasien'>"; }
		}	
		?>		</td>
	  </tr>
	  <form action="home.php?ling=pasien&aksi=simpan" method="post" id="formsign" autocomplete="off">
  <tr>
    <td width="108" height="21">ID Pasien </td>
    <td width="1"><div align="center"><strong>:</strong></div></td>
    <td width="1">&nbsp;</td>
    <td width="505"><? echo $kode_pesanan;?></td>
  </tr>
  <tr>
    <td height="24">Tanggal Daftar </td>
    <td><div align="center"><strong>:</strong></div></td>
    <td>&nbsp;</td>
    <td><input type="text" name="tgldaf" id="tgldaf" value="<?php echo date('Y\-m\-d'); ?>" readonly /></td>
  </tr>
  <tr>
    <td height="24">Nama Pasien</td>
    <td><div align="center"><strong>:</strong></div></td>
    <td>&nbsp;</td>
    <td><input type="text" name="nmps" /></td>
  </tr>
  <tr>
    <td height="24">Umur Pasien </td>
    <td><div align="center"><strong>:</strong></div></td>
    <td>&nbsp;</td>
    <td><input type="text" name="umurps" maxlength="3" size="3"/></td>
  </tr>
   <tr>
    <td height="24">Jenis Kelamin</td>
    <td><div align="center"><strong>:</strong></div></td>
    <td>&nbsp;</td>
    <td><select name="jk" id="jk">
				<option value=" "> </option>
                <option value="L">L</option>
                <option value="P">P</option>
              </select></td>
   </tr>
   <tr>
    <td height="85">Alamat</td>
    <td><div align="center"><strong>:</strong></div></td>
    <td>&nbsp;</td>
    <td><textarea name="almt" cols="25" rows="5"></textarea></td>
   </tr>
  <tr>
    <td height="24">No Telp </td>
    <td><div align="center"><strong>:</strong></div></td>
    <td>&nbsp;</td>
    <td><input type="text" name="telpps" cols="30" rows="5" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="5"><div align="center"><input type="submit" name="submit" value="Simpan">&nbsp;</div></td>
  </tr>
	  </form>
	</table>
	</td>
  </tr>
</table></td></tr>
</table>
</td></tr>
</table>
<table width="100%" bgcolor="#FFFFFF" align="center" border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td colspan="6" bgcolor="#000000"><div align="center" class="style11 style1"><font size="2">Data Pasien </font></div></td>
  </tr>
  <tr bgcolor="#D7D5D6">
    <td width="19%" align="center"><font color="d7d5d6">a</font><font color="#FFFFFF">ID</font><font color="d7d5d6">a</font></td>
	<td width="15%" align="center"><font color="d7d5d6">aaa</font><font color="#FFFFFF">NAMA</font><font color="d7d5d6">aaa</font></td>
	<td width="15%" align="center"><font color="d7d5d6">a</font><font color="#FFFFFF">TGL DAFTAR </font><font color="d7d5d6">a</font></td>
    <td width="15%" align="center"><font color="d7d5d6">aaa</font><font color="#FFFFFF">NO.TLP</font><font color="d7d5d6">aaa</font></td>
  </tr>
  <?php
	  $ambil1="select * from db_pasien order By ID_PASIEN ";
	  $ambil2=mysql_query($ambil1)or die("maaf error");
	  while($ambil3=mysql_fetch_array($ambil2)) {
	  ?>
  <tr>
    <td><font><? echo"$ambil3[ID_PASIEN]";?></font></td>
	<td><font><? echo"$ambil3[NAMA_PASIEN]";?></font></td>
	<td><font><? echo"$ambil3[TGL_DAFTAR]";?></font></td>
    <td><font><? echo"$ambil3[TLP_PASIEN]";?></font></td>
	
  </tr>
  <? } ?>
  <tr>
    <td colspan="6" bgcolor="#000000">&nbsp;</td>
  </tr>
</table>